package cn.edu.paisi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.edu.paisi.entity.Subject;
import cn.edu.paisi.service.ISubjectService;
import cn.edu.paisi.util.RestResult;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author en.edu.paisi
 * @since 2021-03-05
 */
@RestController
@CrossOrigin
public class SubjectController {

	@Autowired
	private ISubjectService subjectService;
	
	@RequestMapping("/addSubject")
	public RestResult<Subject> addSubject(Subject sub){
		subjectService.save(sub);
		return new RestResult<>();
	}
	
	@RequestMapping("/getSubject")
	public RestResult<Subject> getSubject(Integer subId){
		Subject subject = subjectService.getById(subId);
		return  RestResult.ok(subject);
	}
}

